﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;
using System.Globalization;
using System.IO;

namespace KerriganBlog
{
    public class BasePage : System.Web.UI.Page
    {

        protected override void InitializeCulture()
        {
            base.InitializeCulture();
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            string CurrentFilePath = Path.GetFileName(HttpContext.Current.Request.FilePath.ToLower());

            using (ServiceProxy Srv = new ServiceProxy(Request.Cookies))
            {
                if (CurrentFilePath == "login.aspx")
                {
                    if (Srv.isValidTicket)
                    {
                        Response.Redirect("~/ManageArticleHome.aspx");
                        return;
                    }
                }

                if (!Page.IsPostBack)
                {
                    if (!Srv.isValidTicket && CurrentFilePath != "login.aspx")
                        Response.Redirect("~/Login.aspx");
                }
            }
        }



    }
}